

-- Store Chi Tiet Thuoc Tinh
Create Proc spChiTietThuocTinhInsert
@IDLoaiSanPham uniqueidentifier
,@IDThuocTinh uniqueidentifier
AS
BEGIN
Insert Into ChiTietThuocTinh(IDLoaiSanPham,IDThuocTinh)
Values(@IDLoaiSanPham,@IDThuocTinh)
END
GO

Create Proc spChiTietThuocTinhUpdate
@IDLoaiSanPham uniqueidentifier,
@IDThuocTinh uniqueidentifier
AS
BEGIN
UPDATE ChiTietThuocTinh
Set IDLoaiSanPham=@IDLoaiSanPham,IDThuocTinh=@IDThuocTinh

END
GO

Create Proc spChiTietThuocTinhDelete
@IDLoaiSanPham uniqueidentifier,
@IDThuocTinh uniqueidentifier
AS
BEGIN
DELETE ChiTietThuocTinh
WHERE IDLoaiSanPham=@IDLoaiSanPham AND IDThuocTinh=@IDThuocTinh
END
GO

-- Store Chung Loai San Pham
Create Proc spChungLoaiSanPhamInsert
@IDChungLoai uniqueidentifier
,@TenChungLoai nvarchar(50)
AS
BEGIN
Insert Into ChungLoaiSanPham(IDChungLoai,TenChungLoai)
Values(@IDChungLoai,@TenChungLoai)
END
GO

Create Proc spChungLoaiSanPhamUpdate
@IDChungLoai uniqueidentifier,
@TenChungLoai nvarchar(50)
AS
BEGIN
UPDATE ChungLoaiSanPham
Set IDChungLoai=@IDChungLoai,TenChungLoai=@TenChungLoai

END
GO

Create Proc spChungLoaiSanPhamDelete
@IDChungLoai uniqueidentifier
AS
BEGIN
DELETE ChungLoaiSanPham WHERE IDChungLoai=@IDChungLoai
END
GO




-- Store Hinh Anh
Create Proc spHinhAnhInsert
@IDHinhAnh uniqueidentifier
,@IDSanPham uniqueidentifier
,@URL nvarchar(MAX)
AS
BEGIN
Insert Into HinhAnh(IDHinhAnh,IDSanPham,URL)
Values(@IDHinhAnh,@IDSanPham,@URL)
END
GO

Create Proc spHinhAnhUpdate
@IDHinhAnh uniqueidentifier,
@IDSanPham uniqueidentifier,
@URL nvarchar(MAX)
AS
BEGIN
UPDATE HinhAnh
Set IDSanPham=@IDSanPham,URL=@URL
WHERE IDHinhAnh=@IDHinhAnh
END
GO

Create Proc spHinhAnhDelete
@IDSanPham uniqueidentifier
AS
BEGIN
DELETE HinhAnh WHERE IDSanPham=@IDSanPham
END
GO

-- Store Loai San Pham
Create Proc spLoaiSanPhamInsert
@IDLoaiSanPham uniqueidentifier
,@TenLoaiSanPham nvarchar(50)
,@IDChungLoai uniqueidentifier
AS
BEGIN
Insert Into LoaiSanPham(IDLoaiSanPham,TenLoaiSanPham,IDChungLoai)
Values(@IDLoaiSanPham,@TenLoaiSanPham,@IDChungLoai)
END
GO

Create Proc spLoaiSanPhamUpdate
@IDLoaiSanPham uniqueidentifier,
@TenLoaiSanPham nvarchar(50),
@IDChungLoai uniqueidentifier
AS
BEGIN
UPDATE LoaiSanPham
Set TenLoaiSanPham=@TenLoaiSanPham,IDChungLoai=@IDChungLoai
WHERE IDLoaiSanPham=@IDLoaiSanPham
END
GO

Create Proc spLoaiSanPhamDelete
@IDLoaiSanPham uniqueidentifier
AS
BEGIN
DELETE LoaiSanPham WHERE IDLoaiSanPham=@IDLoaiSanPham
END
GO

-- Store Loai Tai Khoan
Create Proc spLoaiTaiKhoanInsert
@IDLoaiTaiKhoan uniqueidentifier
,@TenLoaiTaiKhoan nvarchar(50)
,@Quyen int
AS
BEGIN
Insert Into LoaiTaiKhoan(IDLoaiTaiKhoan,TenLoaiTaiKhoan,Quyen)
Values(@IDLoaiTaiKhoan,@TenLoaiTaiKhoan,@Quyen)
END
GO

Create Proc spLoaiTaiKhoanUpdate
@IDLoaiTaiKhoan uniqueidentifier,
@TenLoaiTaiKhoan nvarchar(50),
@Quyen int
AS
BEGIN
UPDATE LoaiTaiKhoan
Set TenLoaiTaiKhoan=@TenLoaiTaiKhoan,Quyen=@Quyen
WHERE IDLoaiTaiKhoan=@IDLoaiTaiKhoan
END
GO

Create Proc spLoaiTaiKhoanDelete
@IDLoaiTaiKhoan uniqueidentifier
AS
BEGIN
DELETE LoaiTaiKhoan WHERE IDLoaiTaiKhoan=@IDLoaiTaiKhoan
END
GO

-- Store Nha San Xuat
Create Proc spNhaSanXuatInsert
@IDNhaSanXuat uniqueidentifier
,@TenNhaSanXuat nvarchar(50)
AS
BEGIN
Insert Into NhaSanXuat(IDNhaSanXuat,TenNhaSanXuat)
Values(@IDNhaSanXuat,@TenNhaSanXuat)
END
GO

Create Proc spNhaSanXuatUpdate
@IDNhaSanXuat uniqueidentifier,
@TenNhaSanXuat nvarchar(50)
AS
BEGIN
UPDATE NhaSanXuat
Set TenNhaSanXuat=@TenNhaSanXuat
WHERE IDNhaSanXuat=@IDNhaSanXuat
END
GO

Create Proc spNhaSanXuatDelete
@IDNhaSanXuat uniqueidentifier
AS
BEGIN
DELETE NhaSanXuat WHERE IDNhaSanXuat=@IDNhaSanXuat
END
GO

-- Store Noi Dung San Pham
Create Proc spNoiDungSanPhamInsert
@IDSanPham uniqueidentifier
,@IDThuocTinh uniqueidentifier
,@NoiDung nvarchar(50)
AS
BEGIN
Insert Into NoiDungSanPham(IDSanPham,IDThuocTinh,NoiDung)
Values(@IDSanPham,@IDThuocTinh,@NoiDung)
END
GO

Create Proc spNoiDungSanPhamUpdate
@IDSanPham uniqueidentifier,
@IDThuocTinh uniqueidentifier,
@NoiDung nvarchar(50)
AS
BEGIN
UPDATE NoiDungSanPham
Set IDSanPham=@IDSanPham,IDThuocTinh=@IDThuocTinh,NoiDung=@NoiDung

END
GO

Create Proc spNoiDungSanPhamDelete
@IDSanPham uniqueidentifier
AS
BEGIN
DELETE NoiDungSanPham WHERE IDSanPham=@IDSanPham
END
GO


-- Store San Pham
Create Proc spSanPhamInsert
@IDSanPham uniqueidentifier
,@IDLoaiSanPham uniqueidentifier
,@IDNguoiBan uniqueidentifier
,@IDNhaSanXuat uniqueidentifier
,@IsAn bit
,@IsKhuyenMai bit
,@NoiDungKhuyenMai nvarchar(50)
,@NgayTao datetime
,@SoLuotXem int
,@SoLuong int
,@ThoiGianBaoHanh int
,@Gia decimal
,@TenSanPham nvarchar(MAX)
AS
BEGIN
Insert Into SanPham(IDSanPham,IDLoaiSanPham,IDNguoiBan,IDNhaSanXuat,IsAn,IsKhuyenMai,NoiDungKhuyenMai,NgayTao,SoLuotXem,SoLuong,ThoiGianBaoHanh,Gia,TenSanPham)
Values(@IDSanPham,@IDLoaiSanPham,@IDNguoiBan,@IDNhaSanXuat,@IsAn,@IsKhuyenMai,@NoiDungKhuyenMai,@NgayTao,@SoLuotXem,@SoLuong,@ThoiGianBaoHanh,@Gia,@TenSanPham)
END
GO

Create Proc spSanPhamUpdate
@IDSanPham uniqueidentifier,
@IDLoaiSanPham uniqueidentifier,
@IDNguoiBan uniqueidentifier,
@IDNhaSanXuat uniqueidentifier,
@IsAn bit,
@IsKhuyenMai bit,
@NoiDungKhuyenMai nvarchar(50),
@NgayTao datetime,
@SoLuotXem int,
@SoLuong int,
@ThoiGianBaoHanh int,
@Gia decimal,
@TenSanPham nvarchar(MAX)
AS
BEGIN
UPDATE SanPham
Set IDLoaiSanPham=@IDLoaiSanPham,IDNguoiBan=@IDNguoiBan,IDNhaSanXuat=@IDNhaSanXuat,IsAn=@IsAn,IsKhuyenMai=@IsKhuyenMai,NoiDungKhuyenMai=@NoiDungKhuyenMai,NgayTao=@NgayTao,SoLuotXem=@SoLuotXem,SoLuong=@SoLuong,ThoiGianBaoHanh=@ThoiGianBaoHanh,Gia=@Gia,TenSanPham=@TenSanPham
WHERE IDSanPham=@IDSanPham
END
GO

Create Proc spSanPhamDelete
@IDSanPham uniqueidentifier
AS
BEGIN
DELETE SanPham WHERE IDSanPham=@IDSanPham
END
GO

-- Store Tai Khoan
Create Proc spTaiKhoanInsert
@IDTaiKhoan uniqueidentifier
,@TenDangNhap nvarchar(50)
,@MatKhau nvarchar(50)
,@IDLoaiTaiKhoan uniqueidentifier
,@HoTen nvarchar(50)
,@CMND nvarchar(50)
,@GioiTinh bit
,@NgaySinh datetime
,@Email nvarchar(50)
,@DienThoai nvarchar(50)
,@IDTinhThanhPho uniqueidentifier
,@NgayDangKy datetime
,@NgayKetThuc datetime
AS
BEGIN
Insert Into TaiKhoan(IDTaiKhoan,TenDangNhap,MatKhau,IDLoaiTaiKhoan,HoTen,CMND,GioiTinh,NgaySinh,Email,DienThoai,IDTinhThanhPho,NgayDangKy,NgayKetThuc)
Values(@IDTaiKhoan,@TenDangNhap,@MatKhau,@IDLoaiTaiKhoan,@HoTen,@CMND,@GioiTinh,@NgaySinh,@Email,@DienThoai,@IDTinhThanhPho,@NgayDangKy,@NgayKetThuc)
END
GO

Create Proc spTaiKhoanUpdate
@IDTaiKhoan uniqueidentifier,
@TenDangNhap nvarchar(50),
@MatKhau nvarchar(50),
@IDLoaiTaiKhoan uniqueidentifier,
@HoTen nvarchar(50),
@CMND nvarchar(50),
@GioiTinh bit,
@NgaySinh datetime,
@Email nvarchar(50),
@DienThoai nvarchar(50),
@IDTinhThanhPho uniqueidentifier,
@NgayDangKy datetime,
@NgayKetThuc datetime
AS
BEGIN
UPDATE TaiKhoan
Set TenDangNhap=@TenDangNhap,MatKhau=@MatKhau,IDLoaiTaiKhoan=@IDLoaiTaiKhoan,HoTen=@HoTen,CMND=@CMND,GioiTinh=@GioiTinh,NgaySinh=@NgaySinh,Email=@Email,DienThoai=@DienThoai,IDTinhThanhPho=@IDTinhThanhPho,NgayDangKy=@NgayDangKy,NgayKetThuc=@NgayKetThuc
WHERE IDTaiKhoan=@IDTaiKhoan
END
GO

Create Proc spTaiKhoanDelete
@IDTaiKhoan uniqueidentifier
AS
BEGIN
DELETE TaiKhoan WHERE IDTaiKhoan=@IDTaiKhoan
END
GO

-- Store Thuoc Tinh
Create Proc spThuocTinhInsert
@IDThuocTinh uniqueidentifier
,@TenThuocTinh nvarchar(50)
AS
BEGIN
Insert Into ThuocTinh(IDThuocTinh,TenThuocTinh)
Values(@IDThuocTinh,@TenThuocTinh)
END
GO

Create Proc spThuocTinhUpdate
@IDThuocTinh uniqueidentifier,
@TenThuocTinh nvarchar(50)
AS
BEGIN
UPDATE ThuocTinh
Set TenThuocTinh=@TenThuocTinh
WHERE IDThuocTinh=@IDThuocTinh
END
GO

Create Proc spThuocTinhDelete
@IDThuocTinh uniqueidentifier
AS
BEGIN
DELETE ThuocTinh WHERE IDThuocTinh=@IDThuocTinh
END
GO

-- Store Tinh Thanh Pho
Create Proc spTinhThanhPhoInsert
@IDTinhThanhPho uniqueidentifier
,@TenTinhThanhPho nvarchar(50)
AS
BEGIN
Insert Into TinhThanhPho(IDTinhThanhPho,TenTinhThanhPho)
Values(@IDTinhThanhPho,@TenTinhThanhPho)
END
GO

Create Proc spTinhThanhPhoUpdate
@IDTinhThanhPho uniqueidentifier,
@TenTinhThanhPho nvarchar(50)
AS
BEGIN
UPDATE TinhThanhPho
Set TenTinhThanhPho=@TenTinhThanhPho
WHERE IDTinhThanhPho=@IDTinhThanhPho
END
GO

Create Proc spTinhThanhPhoDelete
@IDTinhThanhPho uniqueidentifier
AS
BEGIN
DELETE TinhThanhPho WHERE IDTinhThanhPho=@IDTinhThanhPho
END
GO
